/*
 * @Description: 宠物品种管理
 * @Author: 龙春雨
 * @Date: 2023-04-06 14:07:24
 */
import { rule } from '@/util/validateRules';
import { IS_HOT_DIC, IS_HOT } from '@/const/type';
export const tableOption = (parentCode) => {
  return {
    ...window.$crudMixins.tableOptions,
    viewBtn: false,
    addBtn: true,
    editBtn: true,
    delBtn: true,
    labelWidth: 100,
    searchLabelWidth: 90,
    menuWidth: 130,
    dialogCustomClass: 'dialog-classify',
    span: 24,
    rowParentKey: 'parent',
    rowKey: 'value',
    column: [
      {
        label: '宠物大类',
        prop: 'parentCode',
        span: 12,
        row: true,
        maxlength: 30,
        value: '0',
        type: 'select',
        disabled: true,
        addDisplay: !!parentCode && parentCode !== '0',
        editDisplay: !!parentCode && parentCode !== '0',
        hide: true,
      },
      {
        label: '宠物类型',
        prop: 'name',
        span: 12,
        maxlength: 30,
        fixed: true,
        rules: [
          { required: true, message: '请输入宠物类型！', trigger: 'blur' },
        ],
        overHidden: true,
        search: true,
      },
      {
        label: '分类图片',
        prop: 'pic',
        type: 'upload',
        listType: 'picture-img',
        span: 12,
        align: 'center',
        fileSize: 10 * 1024,
        width: 100,
        accept: '.jpg,.png,.jpeg,.webp,.heic',
        propsHttp: {
          name: 'hash',
          url: 'key',
        },
        oss: 'qiniu',
        fileType: 'img',
        limit: 1,
        cropperOption: {
          autoCropWidth: 294,
          autoCropHeight: 294,
          fixed: true,
          fixedNumber: [1, 1],
        },
        tip: '请上传jpg/png/jpeg/webp/heic类型的文件，最大可上传10M',
        rules: [{ required: true, message: '请上传分类图片', trigger: 'blur' }],
      },
      {
        label: '宠物编码',
        prop: 'code',
        width: 120,
        row: true,
        span: 12,
        overHidden: true,
        editDisabled: true,
        maxlength: 20,
        placeholder: '请输入大写英文、下划线',
        rules: [
          { required: true, message: '请输入宠物编码', trigger: 'blur' },
          { validator: rule.validatorKey, trigger: 'blur' },
        ],
      },
      {
        label: '是否热门',
        prop: 'hotFlag',
        dicData: IS_HOT_DIC,
        type: 'radio',
        value: IS_HOT.NO,
        addDisplay: true,
        editDisplay: true,
        viewDisplay: true,
        overHidden: true,
      },
      {
        label: '说明',
        prop: 'remark',
        addDisplay: false,
        editDisplay: false,
        viewDisplay: false,
        overHidden: true,
      },
      {
        label: '排序',
        prop: 'sort',
        type: 'number',
        value: 1,
        width: 80,
        precision: 0,
        min: 0,
        max: 1000,
        rules: [
          {
            required: true,
            message: '请输入排序',
            trigger: 'blur',
          },
        ],
        row: true,
        span: 6,
      },
      {
        label: '创建时间',
        prop: 'createTime',
        width: 160,
        addDisplay: false,
        editDisplay: false,
        viewDisplay: false,
      },
    ],
    group: [
      {
        label: '说明',
        prop: 'remarkGroup',
        arrow: false,
        labelWidth: 0,
        column: [
          {
            placeholder: '请输入宠物类型说明',
            prop: 'remark',
            type: 'textarea',
            maxlength: 100,
            minRows: 7,
            showWordLimit: true,
          },
        ],
      },
    ],
  };
};
